﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Option_Auth.aspx.cs" Inherits="MsgCenter.Web.Pages.User.Option_Auth"
    MasterPageFile="~/Option.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server">
    <link rel="stylesheet" media="screen" type="text/css" href="<%=ResolveClientUrl("~/JavaScript/Tree/tree.css") %>" />
    <script type="text/javascript" src="<%=ResolveClientUrl("~/JavaScript/Tree/tree.js") %>"></script>
    <script type="text/javascript" src="<%=ResolveClientUrl("~/JavaScript/FirePlat/assets/js/jqGrid/myJqgrid.js") %>"></script>
    <script type="text/javascript">
        var ajaxUrl = "../../Handlers/Handler_User.ashx";
        var hidSelectAuth_ID = "<%=hidSelectAuth.ClientID %>";
        var hidUserID_ID = "<%=hidUserID.ClientID %>";
        var OptionType = "<%=strType %>";
        //******************************** 校验必填项 ********************************
        function CheckSubmit() {
            SubmitData();
            return false;
        }
        function getHidUserID() {
            return $("#" + hidUserID_ID).val();
        }
        function SubmitData() {
            var UserID = getHidUserID();
            var url = ajaxUrl + "?method=SaveUserAuth&OptionType=" + OptionType + "&UserID=" + UserID;
            var s = $("#tree").getTSelectAuth();
            var treeValue = "";
            if (s != null) {
                treeValue = s.join(",");
            }
            $("#" + hidSelectAuth_ID).val(treeValue);
            $.post(url, { SelectAuth: $("#" + hidSelectAuth_ID).val() },
                function (txt) {
                    var jsonData = $.parseJSON(txt);
                    if (jsonData.State == "true") {
                        Close_Reload();
                    }
                    else {
                        showDialogMessage("操作失败:" + jsonData.Message);
                    }
                }
            );
            return false;
        }
        //******************************** 校验必填项 ********************************
        //******************************** 提示信息 ********************************
        function AlertMessage(message) { alert(message); }
        function Close_Reload() {
            window.parent.CBClose_Load();
        }
        //******************************** 提示信息 ********************************
        window.onload = function () {
            RestLoad();
        }
        function LoadSetTree() {
            var o = {
                cbiconpath: "../../images/tree/",
                emptyiconpath: "../../images/tree/s.gif",
                showcheck: true,
                onnodeclick: null
            };
            var UserID = $("#" + hidUserID_ID).val();
            $.ajax({
                type: "GET",
                url: ajaxUrl + "?method=CreateUserAuth&UserID=" + UserID + "",
                data: "rnd=" + Math.random(),
                success: function (msg) {
                    eval("var data =" + msg + ";");
                    o.data = data;
                    $("#tree").treeview(o);
                },
                error: function (msg) {
                    alert("获取数据出现错误:" + msg);
                }
            });
        }
        function RestLoad() {
            document.getElementById("tree").innerHTML = "<img src='../../Images/tree/loading.gif' />";
            window.setTimeout(LoadSetTree, 100);
        }
    </script>
    <style type="text/css">
        .col-sm-6
        {
            padding-left: 0px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="mailContent">
    <asp:HiddenField ID="hidSelectAuth" runat="server" />
    <asp:HiddenField ID="hidUserID" runat="server" />
    <table width="660px" cellpadding="0" cellspacing="0">
        <tr>
            <td width="80px" align="right" height="35px">
                <font color="red">*</font>&nbsp;姓名:
            </td>
            <td width="240px" align="left">
                <input type="text" id="txtName" runat="server" placeholder="" class="col-xs-10 col-sm-5"
                    style="width: 200px" />
            </td>
            <td width="80px" align="right" height="35px">
                <font color="red">*</font>&nbsp;登录名:
            </td>
            <td width="240px" align="left">
                <input type="text" id="txtUserName" runat="server" placeholder="" class="col-xs-10 col-sm-5"
                    style="width: 200px" />
            </td>
        </tr>
        <tr>
            <td width="80px" align="right" height="35px">
                &nbsp;
            </td>
            <td align="left" colspan="4">
                <div class="col-sm-6" style="width: 300px; text-align: left;">
                    <div class="widget-box">
                        <div class="widget-header header-color-blue2">
                            <h4 class="lighter smaller">
                                模块列表</h4>
                        </div>
                        <div class="widget-body">
                            <div class="widget-main padding-8">
                                <div id="tree" style="height: 280px; overflow-x: no; overflow-y: auto;">
                                    <img src="../../Images/tree/loading.gif" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <br />
    <div style="text-align: center">
        <asp:LinkButton ID="linkSave" runat="server" CssClass="btn btn-info" OnClientClick="return CheckSubmit();"><i class="icon-ok bigger-110"></i>保存</asp:LinkButton>
        &nbsp;&nbsp;
        <button class="btn" onclick="window.parent.CBClose();return false;">
            <i class="icon-undo bigger-110"></i>取消
        </button>
    </div>
</asp:Content>
